#!/usr/bin/env python
#coding=utf-8
import json
import redis

def loadjson(file):
    with open(file) as json_file:
        data = json.load(json_file)
        return data

def deleteKeys(host, port, keys):
	r = redis.Redis(host=host, port = port)
	for key in keys:
		print(key)
		d = r.delete(key)
		print(d)
	
def deleteSetElement(host, port, sets):
	r = redis.Redis(host=host, port = port)
	for set in sets:
		print("key: " + set["key"])
		print("value: " + set["value"])
		d = r.zrem(set["key"],set["value"])
		r.zrem("uid:20|listname","list2")
		print(d)

def verifyArrayData(expect, actual):
	for i in range(len(actual)):
		assert str(expect[i]) == actual[i]["data"]

def verifyArrayDataArr(expect, actual):
	for i in range(len(actual)):
		assert str(expect[i]) == actual[i]

def verifyDataExistinArr(data, arr):
	flag = False
	for i in range(len(arr)):
		if str(arr[i]) == data:
			flag = True
			break
	assert flag == True